-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: BaseModel abstract class, primitive Style Transfer, functions for retrieving model metadata #44
Conversation
…d styletransfer screen to example app
…e usage in StyleTransferModel
android/src/main/java/com/swmansion/rnexecutorch/models/BaseModel.kt
Outdated
Show resolved
Hide resolved
android/src/main/java/com/swmansion/rnexecutorch/models/BaseModel.kt
Outdated
Show resolved
Hide resolved
android/src/main/java/com/swmansion/rnexecutorch/models/BaseModel.kt
Outdated
Show resolved
Hide resolved
android/src/main/java/com/swmansion/rnexecutorch/models/BaseModel.kt
Outdated
Show resolved
Hide resolved
third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.mm
Outdated
Show resolved
Hide resolved
return @(method_meta->num_outputs()); | ||
} | ||
|
||
return @-1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.mm
Outdated
Show resolved
Hide resolved
third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.mm
Outdated
Show resolved
Hide resolved
third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.mm
Outdated
Show resolved
Hide resolved
android/src/main/java/com/swmansion/rnexecutorch/models/BaseModel.kt
Outdated
Show resolved
Hide resolved
private fun downloadModel( | ||
url: String, callback: (path: String?, error: Exception?) -> Unit | ||
) { | ||
Fetcher.downloadResource(context, | ||
client, | ||
url, | ||
ResourceType.MODEL, | ||
false, | ||
{ path, error -> callback(path, error) }, | ||
object : ProgressResponseBody.ProgressListener { | ||
override fun onProgress(bytesRead: Long, contentLength: Long, done: Boolean) { | ||
} | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move the callback inside the downloadModel
method, as it is right now is a bit convoluted for no apparent reason (unless there is one I'm missing)
throw Error("18") | ||
} catch (e: Exception) { | ||
//Executorch forward method throws an exception with a message: "Method forward failed with code XX" | ||
val exceptionCode = e.message!!.substring(e.message!!.length - 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this a bit of a hurdle to maintain, what if the error format from ET changes? Let's check if the message matches a regex first or match it against the pattern typed out in the comment, if it doesn't let's then return the whole error message unchanged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are controlling what error message is thrown from executorch, I will modify it to return only code so we overcome overhead with processing whole message
@interface BaseModel : NSObject | ||
{ | ||
@protected | ||
ETModel *module; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a thought, shouldn't this be model
? module
seems confusing since we have ETModule
which is an abstraction over the ETModel
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about it but that's how it was called in ETModel.mm so I wanted to keep it the same here
third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.mm
Outdated
Show resolved
Hide resolved
third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.mm
Outdated
Show resolved
Hide resolved
third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.mm
Outdated
Show resolved
Hide resolved
This PR fixes the issue in iOS ExecuTorch bindings where if the model returned multiple output arrays, only the first one was considered. ## Description <!-- Provide a concise and descriptive summary of the changes implemented in this PR. --> ### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update (improves or adds clarity to existing documentation) ### Tested on - [x] iOS - [ ] Android ### Testing instructions <!-- Provide step-by-step instructions on how to test your changes. Include setup details if necessary. --> ### Screenshots <!-- Add screenshots here, if applicable --> ### Related issues <!-- Link related issues here using #issue-number --> ### Checklist - [x] I have performed a self-review of my code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly - [ ] My changes generate no new warnings ### Additional notes <!-- Include any additional information, assumptions, or context that reviewers might need to understand this PR. -->
…d styletransfer screen to example app
…e usage in StyleTransferModel
…om/software-mansion/react-native-executorch into @norbertklockiewicz/style-transfer
Co-authored-by: mkopcins <[email protected]>
Description
This pull request introduces Model base class on top of which every other model should be built, there's also a primitive implementation of StyleTransferModel and functions for retrieving model metadata. Fix for bindings allowing to return multiple outputs.
During code review don't focus on StyleTransfer Module as it will change and it's for test purposes right now
Don't review:
Type of change
Tested on
Testing instructions
Screenshots
Related issues
Checklist
Additional notes